package com.hcg.distributedtx.controller;

//import com.hcg.distributedtx.cm.service.CmUService;

import com.github.pagehelper.PageInfo;
import com.hcg.distributedtx.domain.User;
import com.hcg.distributedtx.service.cm.CmUService;
import com.hcg.distributedtx.service.hcg.HcgUService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

//import com.hcg.distributedtx.hcg.service.HcgUService;

@RestController
@Slf4j
public class UserController {

    @Resource
    private CmUService cmUserService;
    @Resource
    private HcgUService hcgUserService;

    @PostMapping("/user/cmsave")
    public void cmSaveUser(@RequestBody User user){
        log.info("invoke save function start ---------------------");
        cmUserService.saveUser(user);
        log.info("invoke save function end =======================");
    }

    @PostMapping("/user/hcgsave")
    public void hcgSaveUser(@RequestBody User user){
        log.info("invoke save function start ---------------------");
        hcgUserService.saveUser(user);
        log.info("invoke save function end =======================");
    }

    @PostMapping("/user/listUser")
    public PageInfo<User> listUser(Integer pageNum, Integer pageSize){
        log.info("invoke save function start ---------------------");
        PageInfo<User> pageInfo = cmUserService.listUser(pageNum, pageSize);
        return pageInfo;
    }

    @PostMapping("/user/listUser1")
    public List<User> listUsers(Integer pageNum, Integer pageSize){
        log.info("invoke save function start ---------------------");
        List<User> users = cmUserService.listUsers(pageNum, pageSize);
        return users;
    }

    @PostMapping("/hot/devtools")
    public String hotTool(String s){
        log.info("invoke save function start ---------------------");
        s += "invoke 我save5";
        return s;
    }

    @PostMapping("/hot/dev")
    public String dev(String s){
        log.info("invoke save function start ---------------------");
        s += "invoke save5";
        return s;
    }

}
